package
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import fl.controls.RadioButtonGroup;
	
	public class ExamFour extends MovieClip
	{
		private var radioG:RadioButtonGroup;
		public function ExamFour()
		{
			radioG = new RadioButtonGroup("Radio");
			radioG.addRadioButton(r1);
			radioG.addRadioButton(r2);
			radioG.addRadioButton(r3);
			trace(123);
			addEventFrame();
		}
		
		private function addEventFrame():void
		{
			chaxun.addEventListener(MouseEvent.CLICK, onChaXun);
			mozhang.addEventListener(MouseEvent.CLICK, onMoZhang);
		}
		private var isChaXun:Boolean = false;
		private function onChaXun(e:MouseEvent):void
		{
			trace("查询");
			if(isChaXun) return;
			if(txt1.text == "")
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:getStr()}));
			}
			else
			{
				if(isMoZhang) return;
				gotoAndStop(2);
//				xuanzhong.addEventListener(MouseEvent.CLICK, onSelect);
			}
		}
		
//		private function onSelect(e:MouseEvent):void
//		{
//			
//		}
		private var isSelect:Boolean = false;
		private var isMoZhang:Boolean = false;
		private function onMoZhang(e:MouseEvent):void
		{
			if(xuanzhong.selected)
			{
				if(txt2.text == "" || txt2.text == "\r")
				{
					this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:"请输入抹帐原因!"}));
				}
				else
				{
					notice.visible = true;
					notice.Close.addEventListener(MouseEvent.CLICK, onClose);
					notice.Close2.addEventListener(MouseEvent.CLICK, onClose);
					notice.ok.addEventListener(MouseEvent.CLICK, onOk);
				}
			}
		}
		
		private function onOk(e:MouseEvent):void
		{
			isSelect = true;
			isMoZhang = true;
			gotoAndStop(1);
		}
		
		private function onClose(e:MouseEvent):void
		{
			var dis:DisplayObject = e.currentTarget as DisplayObject;
			dis.removeEventListener(MouseEvent.CLICK,onClose);
			dis.parent.visible = false;
		}
		
		public function getScroe():Object
		{
			var scroe:int = 0;
			if(txt1.text != "") scroe ++;
			if(isChaXun) scroe++;
			if(isMoZhang) scroe ++;
			if(isSelect) scroe ++;
			//			this.dispatchEvent(new ProEvent(ProEvent.SEND_SCORE, {id:1, score:scroe}));
			trace("id:4, scroe:" + scroe);
			return {id:4, scroe:scroe};
		}
		
		private function getStr():String
		{
			var str:String = "";
			trace(radioG.selectedData);
			trace(radioG.selection);
			switch(int(radioG.selectedData))
			{
				case 1:
					str = "请输入客户编号再进行此操作！";
					break;
				case 2:
					str = "请输入银行卡号再进行此操作！";
					break;
				case 3:
					str = "请输入银行账号再进行此操作！";
					break;
			}
			return str;
		}
	}
}